cmake_minimum_required(VERSION 3.15)
project(GPIO_Driver)

set(CMAKE_CXX_STANDARD 14)

set(GPIO_DRIVER_LIB_NAME gpio-drivers)

add_library(${GPIO_DRIVER_LIB_NAME} SHARED src/pwm_driver.cpp src/radar_driver.cpp src/rgb_led_driver.cpp)
add_executable(test src/test.cpp src/pwm_driver.cpp src/radar_driver.cpp src/rgb_led_driver.cpp)

# Self include
target_include_directories(${GPIO_DRIVER_LIB_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_include_directories(test PUBLIC ${CMAKE_SOURCE_DIR}/include)
set(LIB_PUBLIC_HEADERS
    ${CMAKE_SOURCE_DIR}/include/pwm_driver.h
    ${CMAKE_SOURCE_DIR}/include/radar_driver.h
    ${CMAKE_SOURCE_DIR}/include/rgb_led_driver.h
        )
set_target_properties(${GPIO_DRIVER_LIB_NAME} PROPERTIES PUBLIC_HEADER "${LIB_PUBLIC_HEADERS}")

# JetsonGPIO
target_link_libraries(${GPIO_DRIVER_LIB_NAME} libJetsonGPIO.a)
target_link_libraries(test libJetsonGPIO.a)

# Thread
FIND_PACKAGE(Threads)
TARGET_LINK_LIBRARIES(test ${CMAKE_THREAD_LIBS_INIT})

# Installation
install(TARGETS ${GPIO_DRIVER_LIB_NAME}
        LIBRARY DESTINATION lib
        ARCHIVE DESTINATION lib
        RUNTIME DESTINATION bin
        PUBLIC_HEADER DESTINATION include
        )
